package com.monkeygroup.mygoplus.ecchat.ui.chatting.holder;

import android.media.Image;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.monkeygroup.mygoplus.R;

/**
 * Created by Administrator on 2017/6/3.
 */
public class SharedViewHolder extends BaseHolder {
    public View chattingContent;
    public TextView readTv;
    public LinearLayout layout_content;
    public ImageView friend_head;
    public TextView friend_nickname;

    /**
     * @param type
     */
    public SharedViewHolder(int type) {
        super(type);

    }

    public BaseHolder initBaseHolder(View baseView, boolean receive) {
        super.initBaseHolder(baseView);

        chattingTime = (TextView) baseView.findViewById(R.id.chatting_time_tv);
        chattingUser = (TextView) baseView.findViewById(R.id.chatting_user_tv);

        layout_content = (LinearLayout) baseView.findViewById(R.id.layout_content);
        friend_head = (ImageView) baseView.findViewById(R.id.friend_head);
        friend_nickname = (TextView) baseView.findViewById(R.id.friend_nickname);

        checkBox = (CheckBox) baseView.findViewById(R.id.chatting_checkbox);
        chattingMaskView = baseView.findViewById(R.id.chatting_maskview);
        chattingContent = baseView.findViewById(R.id.chatting_content_area);

        if (!receive) {
            readTv = (TextView) baseView.findViewById(R.id.tv_read_unread);
        }

        if (receive) {
            type = 21;
            return this;
        }


        uploadState = (ImageView) baseView.findViewById(R.id.chatting_state_iv);
        progressBar = (ProgressBar) baseView.findViewById(R.id.uploading_pb);
        type = 20;
        return this;
    }

    /**
     * @return
     */
    public ImageView getChattingState() {
        if (uploadState == null) {
            uploadState = (ImageView) getBaseView().findViewById(R.id.chatting_state_iv);
        }
        return uploadState;
    }

    /**
     * @return
     */
    public LinearLayout getSharedContent() {
        if (layout_content == null) {
            layout_content = (LinearLayout) baseView.findViewById(R.id.layout_content);
        }
        return layout_content;
    }

    /**
     * @return
     */
    public ProgressBar getUploadProgressBar() {
        if (progressBar == null) {
            progressBar = (ProgressBar) getBaseView().findViewById(R.id.uploading_pb);
        }
        return progressBar;
    }

    @Override
    public TextView getReadTv() {
        return readTv;
    }

}